#include "Camera.h"

Camera::Camera(void)
{
	movement_rate = 100.0f;
	rotation_rate = float(AlphaMath::DegToRadians(1.0f));
	cameraFrame.setOrigin(0,1000,1000);
	cameraFrame.rotateWorld(AlphaMath::DegToRadians(45.0), 1, 0, 0);
	//cameraFrame.rotateLocalX(AlphaMath::DegToRadians(-90.0));
}

Camera::~Camera(void)
{
}

// This function alows the camera to move along the worlds z axis regardless of the cameras own orientation
void Camera::moveForward()
{
	AlphaVector temp;
	temp = cameraFrame.getForwardVector();
	/*float x = cameraFrame.getOriginX() + (temp.getX() * movement_rate);*/
	float x = cameraFrame.getOriginX();
	float y = cameraFrame.getOriginY();
	//float z = cameraFrame.getOriginZ() + (temp.getZ() * movement_rate * 10);
	float z = cameraFrame.getOriginZ() + 2;
	cameraFrame.setOrigin(x,y,z);
}

// This function alows the camera to move along the worlds z axis regardless of the cameras own orientation
void Camera::moveBackward()
{
	AlphaVector temp;
	temp = cameraFrame.getForwardVector();
	/*float x = cameraFrame.getOriginX() + (temp.getX() * -movement_rate);*/
	float x = cameraFrame.getOriginX();
	float y = cameraFrame.getOriginY();
	/*float z = cameraFrame.getOriginZ() + (temp.getZ() * -movement_rate);*/
	float z = cameraFrame.getOriginZ() - 2;
	cameraFrame.setOrigin(x,y,z);
}


// The following two functions are used to differentiate camera behaviour between objects that will remain stationary to the camera like a skybox,
// or that will move independantly of the camera like actors or scene objects
void Camera::setCameraStatic(AlphaMatrixStack* imatrix)
{
	imatrix->loadMatrix(cameraFrame.getCameraMatrix(true));
}

void Camera::setCamera(AlphaMatrixStack* imatrix)
{
	imatrix->loadMatrix(cameraFrame.getCameraMatrix());
}

void Camera::update(AlphaVector iorigin, float iangle)
{
}